import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
	list = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/list',
	save = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/add',
	edit = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/edit',
	deleteOne = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/delete',
	deleteBatch = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/deleteBatch',
	importExcel = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/importExcel',
	exportXls = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/exportXls',
	bsTraveldispatchCarleaderdispatchrecordList = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/listBsTraveldispatchCarleaderdispatchrecordByMainId',
	bsTraveldispatchCarleaderdispatchrecordSave = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/addBsTraveldispatchCarleaderdispatchrecord',
	bsTraveldispatchCarleaderdispatchrecordEdit = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/editBsTraveldispatchCarleaderdispatchrecord',
	bsTraveldispatchCarleaderdispatchrecordDelete = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/deleteBsTraveldispatchCarleaderdispatchrecord',
	bsTraveldispatchCarleaderdispatchrecordDeleteBatch = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/deleteBatchBsTraveldispatchCarleaderdispatchrecord',
	bsTravelgroupTourtravellinefinalbindcarrecordList = '/journey/bsTravelgroupMaintuortravellinerecord/listBsTravelgroupTourtravellinefinalbindcarrecordByMainId',
	bsTravelgroupTourtravellinefinalbindcarrecordSave = '/journey/bsTravelgroupMaintuortravellinerecord/addBsTravelgroupTourtravellinefinalbindcarrecord',
	bsTravelgroupTourtravellinefinalbindcarrecordEdit = '/journey/bsTravelgroupMaintuortravellinerecord/editBsTravelgroupTourtravellinefinalbindcarrecord',
	bsTravelgroupTourtravellinefinalbindcarrecordDelete = '/journey/bsTravelgroupMaintuortravellinerecord/deleteBsTravelgroupTourtravellinefinalbindcarrecord',
	bsTravelgroupTourtravellinefinalbindcarrecordDeleteBatch = '/journey/bsTravelgroupMaintuortravellinerecord/deleteBatchBsTravelgroupTourtravellinefinalbindcarrecord',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
	defHttp.get({ url: Api.list, params });

/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.edit : Api.save;
	return defHttp.post({ url: url, params });
}
/**
 * 列表接口
 * @param params
 */
export const bsTraveldispatchCarleaderdispatchrecordList = (params) => {
	if (params['finalbindcarrecordid']) {
		return defHttp.get({ url: Api.bsTraveldispatchCarleaderdispatchrecordList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const bsTraveldispatchCarleaderdispatchrecordDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.bsTraveldispatchCarleaderdispatchrecordDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const bsTraveldispatchCarleaderdispatchrecordDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.bsTraveldispatchCarleaderdispatchrecordDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const bsTraveldispatchCarleaderdispatchrecordSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.bsTraveldispatchCarleaderdispatchrecordEdit : Api.bsTraveldispatchCarleaderdispatchrecordSave;

	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const bsTraveldispatchCarleaderdispatchrecordImportUrl = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/importBsTraveldispatchCarleaderdispatchrecord'

/**
 * 导出
 */
export const bsTraveldispatchCarleaderdispatchrecordExportXlsUrl = '/jounery/bsTravelgroupTourtravellinefinalbindcarrecord/exportBsTraveldispatchCarleaderdispatchrecord'
/**
 * 列表接口
 * @param params
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordList = (params) => {
	if (params['travelgroupid']) {
		return defHttp.get({ url: Api.bsTravelgroupTourtravellinefinalbindcarrecordList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.bsTravelgroupTourtravellinefinalbindcarrecordDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.bsTravelgroupTourtravellinefinalbindcarrecordDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.bsTravelgroupTourtravellinefinalbindcarrecordEdit : Api.bsTravelgroupTourtravellinefinalbindcarrecordSave;

	//组合车牌，司机姓名，电话,搭档姓名。电话，领队工资
	let ext = {
		plateNum: params.plateNum || '',
		cooperatePhone: params.cooperatePhone || '',
		cooperaterName: params.cooperaterName || '',
		driverPhone: params.driverPhone || '',
		driverName: params.driverName || '',
		totalSalary: params.totalSalary || '',
		salaryType: params.salaryType || '',
		msg: params.msg || '' //说明
	}
	params.extinfor = JSON.stringify(ext)


	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordImportUrl = '/journey/bsTravelgroupMaintuortravellinerecord/importBsTravelgroupTourtravellinefinalbindcarrecord'

/**
 * 导出
 */
export const bsTravelgroupTourtravellinefinalbindcarrecordExportXlsUrl = '/journey/bsTravelgroupMaintuortravellinerecord/exportBsTravelgroupTourtravellinefinalbindcarrecord'